{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=2816
  Verdict: Accepted
}
var n,i,c:longint; a:int64; p:array[1..100010,1..2] of longint;
procedure qsort(l,r:longint);
var i,j,x,y:longint;
begin
i:=l;
j:=r;
x:=p[(l+r) div 2][1];
repeat
  while p[i][1]<x do inc(i);
  while p[j][1]>x do dec(j);
  if i<=j then begin
    y:=p[i][1];
    p[i][1]:=p[j][1];
    p[j][1]:=y;
    y:=p[i][2];
    p[i][2]:=p[j][2];
    p[j][2]:=y;
    inc(i);
    dec(j);
  end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
Assign(input,'input.txt');
Assign(output,'output.txt');
reset(input);
rewrite(output);
read(n,a);
for i:=1 to n do read(p[i][1],p[i][2]);
qsort(1,n);
i:=1;
c:=0;
while (p[i][1]<=a) and (i<=n) do begin
  inc(c);
  inc(a,p[i][2]);
  inc(i);
end;
write(c);
end.